package com.mysoft.main.main.thread;

import rx.internal.schedulers.CachedThreadScheduler;

import java.util.concurrent.*;

/**
 * @Author: JohnCoding
 * @Description:
 * @date: 2020/7/4 10:22
 */
public class MyThread implements Callable<String> {
    @Override
    public String call() throws Exception {
        System.out.println("当前线程：" + Thread.currentThread());
        Thread.sleep(10000);
        return "hello, this is my first thread for Callable";
    }


    public static void main(String[] args) throws Exception {
//        ExecutorService service = Executors.newCachedThreadPool();
        FutureTask<String> task = new FutureTask<>(new MyThread());
        Thread thread = new Thread(task);
        System.out.println("当前线程：" + Thread.currentThread());
        thread.start();
        System.out.println("111111");
        System.out.println(task.get());
    }
}
